﻿<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:local="clr-namespace:Stromverbrauch" 
             xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit" 
             xmlns:Chromes="clr-namespace:Xceed.Wpf.Toolkit.Chromes;assembly=WPFToolkit.Extended" 
             x:Class="AddConsumptionView"
             d:DesignHeight="387" d:DesignWidth="546"
             mc:Ignorable="d">
  <UserControl.Resources>
    <local:BindingProxy x:Key="proxy" Data="{Binding .}"/>
  </UserControl.Resources>
  <Grid>
    <Grid.RowDefinitions>
      <RowDefinition Height="180"/>
      <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
    <ComboBox Height="23" Margin="0,33,10,0" ItemsSource="{Binding UserList}" VerticalAlignment="Top" SelectedItem="{Binding SelectedUser}" DisplayMemberPath="Name" HorizontalAlignment="Right" Width="228"/>
    <Button IsDefault="True" Focusable="False" Content="Hinzufügen" Command="{Binding AddConsumptionCommand}" CommandParameter="{Binding Text, ElementName=NewConsumption}" Margin="0,120,10,0" VerticalAlignment="Top" HorizontalAlignment="Right" Width="228"/>
    <TextBox TextAlignment="Right" IsEnabled="False" x:Name="LastConsumption" Text="{Binding LastConsumption.Consumption}" Focusable="False" Height="23" Margin="10,33,256,0" TextWrapping="Wrap" VerticalAlignment="Top"/>

    <TabControl  Grid.Row="1" Margin="10,0,10,10">
      <TabItem Header="Liste">
        <ListView x:Name="ListViewHistory" Grid.Row="1" ItemsSource="{Binding ConsumptionsByUserInverted}" DisplayMemberPath="" SelectedItem="{Binding SelectedItem}" >
          <ListView.ContextMenu>
            <ContextMenu>
              <MenuItem Header="Delete" Command="{Binding Data.DeleteCommand, Source={StaticResource proxy}}"/>
            </ContextMenu>
          </ListView.ContextMenu>
        </ListView>
      </TabItem>
      <TabItem Header="Grafik">
        <local:ConsumptionHistory></local:ConsumptionHistory>        
      </TabItem>
    </TabControl>

    <Button Visibility="Collapsed" Content="Save" Command="{Binding SaveCommand}" HorizontalAlignment="Left" Margin="10,66,0,0" VerticalAlignment="Top" Width="280"/>
    <xctk:DateTimeUpDown IsEnabled="{Binding IsChecked, ElementName=UseDate}" Value="{Binding SelectedDateTime}" Margin="28,122,256,0" VerticalAlignment="Top"/>
    <CheckBox IsChecked="{Binding DateTimeManualEdit}" x:Name="UseDate" HorizontalAlignment="Left" Margin="10,125,0,0" VerticalAlignment="Top"/>
    <xctk:DoubleUpDown FontSize="25" FormatString="##.00" Value="{Binding NewConsumption}" x:Name="NewConsumption" Focusable="True" Margin="10,66,256,0" VerticalAlignment="Top" Height="51"/>
    <!--Command="{Binding CheckDateTimeCommand}" CommandParameter="{Binding ElementName=UseDate, Path=IsChecked}"-->
    <xctk:WatermarkTextBox Text="{Binding Comment, UpdateSourceTrigger=PropertyChanged}" Margin="0,66,10,0" TextWrapping="Wrap" Watermark="Kommentar eingeben" VerticalAlignment="Top" Height="49" HorizontalAlignment="Right" Width="228"/>
    <Label Content="Verbraucher" VerticalAlignment="Top" Margin="0,10,163,0" HorizontalAlignment="Right" Width="75"/>
    <Label Content="Letzer Zählerstand" Margin="10,10,0,0" VerticalAlignment="Top" HorizontalAlignment="Left" Width="107"/>

  </Grid>
</UserControl>